package com.xm.strategy;

import com.xm.util.StringUtil;

import java.math.BigDecimal;
import java.math.RoundingMode;

public class Client {
    public static void main(String[] args) {
        BigDecimal amount = new BigDecimal(StringUtil.formatDecimal(100.253, 2, RoundingMode.HALF_UP));

        //使用支付宝支付
        AlipayStrategy alipay = new AlipayStrategy("user@alipay.com");
        PaymentContext context = new PaymentContext(alipay);
        context.executePayment(amount);

        //使用微信支付
        WechatPayStrategy wechatPay = new WechatPayStrategy("openid_123456");
        context = new PaymentContext(wechatPay);
        context.executePayment(amount);

        //使用银行卡支付
        BankCardStrategy bankCard = new BankCardStrategy("1234-5678-9876-5432", "123");
        context = new PaymentContext(bankCard);
        context.executePayment(amount);
    }
}
